package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.MallIntegrationDO;
import com.starlink.model.request.MallIntegrationRequest;
import com.starlink.model.vo.MallIntegrationVO;
import com.starlink.model.vo.mall.AdminIntegratonArticlesVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface MallIntegrationMapper extends BaseMapper<MallIntegrationDO> {
    MallIntegrationDO selectDOById(Long id);
    List<MallIntegrationDO> selectDOList(MallIntegrationDO mallIntegration);
    int insertDO(MallIntegrationDO mallIntegration);
    int batchInsertDO(List<MallIntegrationDO> mallIntegrationDOList);
    int updateDO(MallIntegrationDO mallIntegration);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from mall_integration",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") MallIntegrationRequest param);
    List<MallIntegrationVO> pageQuery(MallIntegrationRequest request);

    List<Long> selectDOByArticlesId(@Param("id")Long id);

    List<MallIntegrationVO> pageList(MallIntegrationRequest request);

    List<Long> selectInventoryBySpecificationId(@Param("specificationId")Long specificationId);

    List<AdminIntegratonArticlesVO> pageQueryArticles();

    MallIntegrationVO selectByIdOverrride(@Param("id")Long id);
}